import {Module} from 'vuex'

const tagbars: Module<any, any> = {
    namespaced: true,
    state: () => ({
        visitedRoutes: []
    }),
    mutations: {
        addVisitedRoute(state, route) {
            let target = state.visitedRoutes.find((x: { path: any }) => x.path === route.path)
            if (target) {
                if (route.fullPath !== target.fullPath)
                    Object.assign(target, route)
            }
            else {
                state.visitedRoutes.push(Object.assign({}, route))
            }


        }
    },
    getters: {
        login: state => state.isLoggedIn
    },
}


export default tagbars
